<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id='app' v-cloak>
    <h2>{{message}}</h2>
    <cpn2></cpn2>
    <cpn1></cpn1>
  </div>
  <script src='../js/vue.js'></script>
  <script>
    // 1.创建组件
    //子组件
    const cpn1 = Vue.extend({
      template: `<div><h2>我是组件1</h2></div>`
    });
    //父组件
    const cpn2 = Vue.extend({
      template: `<div>
        <h2>我是组件2</h2>
        <cpn1></cpn1>
        </div>`,
      components: {
        cpn1: cpn1
      }
    });
    const app = new Vue({
      el: '#app',
      data: {
        message: 'hello Vue'
      },
      components: {
        cpn2: cpn2,
        cpn1: cpn1
      }
    })
  </script>
  <style>
    [v-cloak] {
      display: none;
    }
  </style>
</body>

</html>